package satir.testcase.cell;


import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import satir.card.ActCard;
import satir.card.Card;
import satir.card.Deck;
import satir.cell.ActCell;
import satir.cell.Cell;
import satir.player.Player;

public class ActCell_cellAction_1 extends TestCase{

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}
	
	/**
	 * Step number : 1
	 * Goal: Trigger an act card
	 */
	@Test
	public void testCellAction() {
		class DeckStub extends Deck{
			@Override
			public Card drawCard(){
				return new ActCardStub();
			}
			class ActCardStub extends ActCard{
				public ActCardStub(){
					super("name","Description");
				}
				@Override
				public void activateCard(Player player){
					System.out.println("---Act Card---");
					System.out.println("Act Card 1");
					System.out.println("Please sing 1 song with any family member.");
				}
			}
		}
		final ByteArrayOutputStream systemOut = new ByteArrayOutputStream();
		System.setOut(new PrintStream(systemOut));
		Deck deck = new DeckStub();
		Cell target = new ActCell(7, 5, '*', '|', deck);
		target.cellAction(null);
		String output = systemOut.toString();
		int nameStartIndex = output.indexOf('\n') + 1;
		int descriptionStartIndex = output.indexOf('\n', nameStartIndex)+1;
		String actualResult = output.substring(nameStartIndex, output.indexOf('\n', nameStartIndex)-1);
		actualResult += output.substring(descriptionStartIndex, output.indexOf('\n', descriptionStartIndex)-1);
		System.out.println(actualResult);
		assertEquals("Act Card 1Please sing 1 song with any family member.", actualResult);
	}
}
